package com.ht.medicaltreatment.view

import android.app.Dialog
import android.content.Context
import android.content.Intent
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import androidx.recyclerview.widget.LinearLayoutManager
import com.blankj.utilcode.util.LogUtils
import com.blankj.utilcode.util.ToastUtils
import com.ht.medicaltreatment.R
import com.ht.medicaltreatment.adapter.MultiReplaceAdapter
import com.xgst.lib.utils.ActivityLifecycleManager
import com.xgst.lib.utils.ScreenUtils
import kotlinx.android.synthetic.main.dialog_replace_caixue_mulite_layout.*
import kotlinx.android.synthetic.main.dialog_replace_layout.*
import kotlinx.android.synthetic.main.dialog_replace_layout.tvSubmit
import kotlinx.android.synthetic.main.dialog_replace_layout.tvUID

//多管替换
class MuliteReplaceCaiXueDialog(context: Context) : Dialog(context, R.style.dialogStyle) {

    private lateinit var mClick:(String,Int) -> Unit
    private var mPosition = -1

    init {
        val view =
            LayoutInflater.from(context).inflate(R.layout.dialog_replace_caixue_mulite_layout, null, false)
        setContentView(view)
        val attributes = window!!.attributes
        attributes.width= ScreenUtils.dp2px(context,300)
        //attributes.height= ScreenUtils.dp2px(context,300)
        window!!.attributes = attributes
        setCancelable(true)
        tvSubmit.setOnClickListener {
            if(tvUID.text == null){
                ToastUtils.showShort("没有UID数据")
                return@setOnClickListener
            }
            mClick(tvUID.text.toString(),mPosition)
        }
        val adapter = MultiReplaceAdapter()
        recyclerView.layoutManager = LinearLayoutManager(context)

    }

    fun showDialog(position:Int,onClick:(String,Int)->Unit){
        mPosition = position
        mClick = onClick
        show()
    }

    fun setUID(uid:String?){
        tvUID.text = uid
    }

}